package com.esun.cheetah.view.setting.connect;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public class ConnectionChangeReceiver extends BroadcastReceiver {

	@Override
	public void onReceive(Context context, Intent intent) {
		ConnectivityManager connectivityManager = (ConnectivityManager) context
				.getSystemService(Context.CONNECTIVITY_SERVICE);
		NetworkInfo mobNetInfo = connectivityManager
				.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
		NetworkInfo wifiNetInfo = connectivityManager
				.getNetworkInfo(ConnectivityManager.TYPE_WIFI);

		if (!mobNetInfo.isConnected() && !wifiNetInfo.isConnected()) {
		}
	}

	private static IntentFilter filter = null;

	public static IntentFilter getIntentFilter() {

		if (filter == null) {
			return filter = new IntentFilter(
					ConnectivityManager.CONNECTIVITY_ACTION);
		} else {
			return filter;
		}
	}

	private static ConnectionChangeReceiver connectionChangeReceiver = null;

	public static ConnectionChangeReceiver getConnectionChangeReceiver() {

		if (connectionChangeReceiver == null) {
			return connectionChangeReceiver = new ConnectionChangeReceiver();
		} else {
			return connectionChangeReceiver;
		}
	}
}
